a = input()
d = []
s = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
for k in a.split():
    if k not in s or len(a.split()) < 3 or len(a.split()) > 3 or a.split()[0] == "zero":
        print("Wrong input")
        exit()
    elif k == "zero":
        f = 0
        d.append(f)
    elif k == "one":
        f = 1
        d.append(f)
    elif k == "two":
        f = 2
        d.append(f)
    elif k == "three":
        f = 3
        d.append(f)
    elif k == "four":
        f = 4
        d.append(f)
    elif k == "five":
        f = 5
        d.append(f)
    elif k == "six":
        f = 6
        d.append(f)
    elif k == "seven":
        f = 7
        d.append(f)
    elif k == "eight":
        f = 8
        d.append(f)
    elif k == "nine":
        f = 9
        d.append(f)
sa = ""
for i in d:
    sa += str(i)
a1 = int(sa)
s1 = 0
for k in range(2, a1 // 2 + 1):
    if (a1 % k == 0):
        s1 = s1 + 1
if (s1 <= 0):
    flag = "t"
    print(a1)
else:
    flag = "f"
if flag == "f":
    z1 = a1
    z2 = a1
    while flag != "t":
        z1 = z1 - 1
        for k in range(2, z1 // 2 + 1):
            if (z1 % k == 0):
                s1 = s1 + 1
        if (s1 <= 0):
            print(z1)
            flag = "t"
            exit()
        else:
            flag = "f"
            s1 = 0
            z2 = z2 + 1
            for k in range(2, z2 // 2 + 1):
                if (z2 % k == 0):
                    s1 = s1 + 1
            if (s1 <= 0):
                print(z2)
                flag = "t"
                exit()
            else:
                flag = "f"
                s1 = 0



